module teapo.typescript { export class TypeScriptService { service: ts.LanguageService;
compilerOptions: ts.CompilerOptions;
cancellation: ts.CancellationToken = null;
defaultLibFilename = '#lib.d.ts';
log: (text: string) => void = null;
private _scriptFileNames: string[] = null;
private _scripts: { [file: string]: TypeScript.IScriptSnapshot; } = {}; var factory = ts.createLanguageService(
addFile(file: string, doc: CodeMirror.Doc);
addFile(file: string, text: string);
addFile(file: string, content: any){ removeFile(file: string) { private _createRegistry() { return ts.createDocumentRegistry();
private _createHost(): ts.LanguageServiceHost { getCompilationSettings: () => this.compilerOptions,
getScriptFileNames: () => { if (!this._scriptFileNames) { this._scriptFileNames = objectKeys(this._scripts);
this._scriptFileNames.sort();
return this._scriptFileNames;
getScriptVersion: (file) => { var script = <CodeMirrorScriptSnapshot>this._scripts[file];
return script.version ? script.version + '' : '0';
getScriptIsOpen: () => true,
getScriptSnapshot: (file) => this._scripts[file],
getLocalizedDiagnosticMessages: () => null,
getCancellationToken: () => this.cancellation,
getCurrentDirectory: () => this.currentDirectory,
getDefaultLibFilename: () => this.defaultLibFilename,
if (typeof console !== 'undefined')